program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var a,b,c,n,i,max,min:integer;
  var fin,fout:textfile;
  var mass: array of integer;
begin
assignfile(fin,'input.txt');
reset(fin);
assignfile(fout,'output.txt');
rewrite(fout);
read(fin,a);
setlength(mass,a-1);
for i:=0 to a-1 do
begin
read(fin,b);
mass[i]:=b;
end;
max:=mass[0];
min:=mass[0];
for i:=0 to a-1 do
begin
if (max<mass[i]) then
max:=mass[i];
if (min>mass[i]) then
min:=mass[i];
end;
n:=max+min;
writeln(fout,n);
closefile(fout);
closefile(fin);
end.

